﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Linq;
using WPFExcelReport.Helpers;
using System.Windows.Input;
using System.Windows.Controls;
namespace WPFExcelReport
{
    /// <summary>
    /// 专用于布卷剪布
    /// </summary>
    public partial class TWBCUT
    {

        public TWBCUT()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWBBST();
            this.DataContext = MV;
            InitializeComponent(); 
        }
        
        
        public override void NewCommand(object sender, System.Windows.RoutedEventArgs e)
        {           
            if (dwMaster == null)
                return;
            if (dwMaster["WBBAUFLFD"].ToString() != "000000")
            {
                MessageBox.Show("已经被留位，需要先取消留位");
                return;
            }
            IsSaved = false;//变更后，触发需要获取的界面的更新
            TMV.CUTWB(dwMaster, CMTR, RUNID);
            IsSaved = true;
            vwMaster.View.MoveCurrentToFirst();
            
            base.NewCommand(sender, e);
        }  
        public override void OnSTKNRChg(string value)
        {
            if (value.Length == 0)
                return; 
            if (!IsLoaded)
                return;
            dwData = TBMain.NewRow();
            dwData["WBBMANDANT"] = app.Mandant;
            dwData["WBBSTKNR"] = value;
            SResult = TMV.QueryWBBST(dwData, 13);
            MergeData(SResult, true); 
            base.OnSTKNRChg(value);
        }
    }
}
